package movee.jpa.multi.source.dao.primary;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import movee.jpa.multi.source.constant.ChangeType;
import movee.jpa.multi.source.constant.OperationStatus;

import javax.persistence.Column;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.MappedSuperclass;
import java.sql.Timestamp;

/**
 *
 *
 * @author movee
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@SuperBuilder
@MappedSuperclass
public class BaseOperationSheetDao extends BaseOperationSheet {

    /**
     * 操作单变更类型，如一般变更、预授权变更
     */
    @Column(name = "change_type")
    @Enumerated(EnumType.STRING)
    private ChangeType changeType;

    /**
     * 操作单状态，如：created,executing,success,fail
     */
    @Column(name = "status")
    @Enumerated(EnumType.STRING)
    private OperationStatus status;

    /**
     * 当前操作人
     */
    @Column(name = "curr_operator")
    private String currOperator;

    /**
     * 操作单总的原子操作数
     */
    @Column(name = "total_atomic_op_count")
    private Integer totalAtomicOpCount;


    /**
     * 自上次提交后是否被修改，0：未修改；1：已修改
     */
    @Column(name = "is_modified")
    private Boolean modified;

    /**
     * 是否已删除，true：已删除；false：未删除
     */
    @Column(name = "is_delete")
    private Boolean delete;

    /**
     * 操作单创建人
     */
    @Column(name = "create_user")
    private String createUser;

    /**
     * 操作单最后修改人
     */
    @Column(name = "update_user")
    private String updateUser;

    /**
     * 操作单创建时间
     */
    @Column(name = "create_time")
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    // @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp createTime;

    /**
     * 操作单最后更新时间
     */
    @Column(name = "update_time")
    // @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    // @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Timestamp updateTime;

    /**
     * 操作花费的时间，单位为毫秒
     */
    @Column(name = "duration_ms")
    private Long durationMs;

    /**
     * 补充说明信息
     */
    @Column(name = "notes")
    private String notes;

}

